﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Boxie
{
    static class Program
    {
        public static string BUILD = "012";
        [STAThread]
        static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                if (args[0] == "-update")
                {
                    // wait for process to close
                    string proc = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
                    bool running = true;
                    while (running)
                    {
                        System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName(proc);
                        if (processes.Length == 1)
                            running = false;
                    }
                    // copy
                    System.IO.File.Copy(System.IO.Path.GetTempPath() + "Boxie.exe", args[1], true);
                    // run
                    System.Diagnostics.Process.Start(args[1]);
                    // finished!
                    return;
                }
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmBoxie(args));
        }
    }
}
